﻿using BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tools;
using 纺织贸易管理系统;

namespace 后整理管理系统.其他窗体
{
    public partial class 回填信息 : Sunny.UI.UIForm
    {
        public 回填信息()
        {
            InitializeComponent();
        }

        public danjumingxitable Mingxi { get;  set; }

        private void 回填信息_Load(object sender, EventArgs e)
        {
            txt上卷支数.Text=Mingxi.UpRolledRolls.ToString();
            txt上卷米数.Text=Mingxi.UpRolledNum.ToString();
            txt退卷支数.Text=Mingxi.ExitsRoll.ToString();
            txt退卷米数.Text=Mingxi.ExitsNum.ToString();
            txt备注.Text = Mingxi.beizhu;
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            try
            {
                Mingxi.UpRolledRolls = Convert.ToDecimal(txt上卷支数.Text);
                Mingxi.UpRolledNum = Convert.ToDecimal(txt上卷米数.Text);
                Mingxi.ExitsRoll = Convert.ToDecimal(txt退卷支数.Text);
                Mingxi.ExitsNum = Convert.ToDecimal(txt退卷米数.Text);
                Mingxi.beizhu = txt备注.Text;
                销售发货单BLL.CalculateShrinkage(Mingxi);
                using (var trans=Connect.dbcontext.UseTran())
                {                   
                    Connect.dbcontext.Updateable(Mingxi).ExecuteCommand();
                    trans.CommitTran();
                    this.Close();
                }
            }catch(Exception ex)
            {
                ShowMessageBox.ShowErrorBox("保存的时候发生了错误："+ex.Message);
                return;
            }
        }
    }
}
